package com.zhang.buiness.amaster.workserver.client.fallback;

import com.zhang.buiness.amaster.workserver.client.fegin.ConfigEnvServiceClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 *
 * 相比于fallBack,可以打印出 fallBack的异常信息
 */
@Component
@Slf4j
public class ConfigEnvServiceClientFallBackFactory implements FallbackFactory<ConfigEnvServiceClient> {

    private final ConfigEnvServiceClientFallBack configEnvServiceClientFallBack;

    public ConfigEnvServiceClientFallBackFactory(ConfigEnvServiceClientFallBack configEnvServiceClientFallBack) {
        this.configEnvServiceClientFallBack = configEnvServiceClientFallBack;
    }


    @Override
    public ConfigEnvServiceClient create(Throwable throwable) {
       // log.error("ConfigEnvServiceClient fall Back {}",throwable.getMessage(),throwable);
        return configEnvServiceClientFallBack;
    }
}
